import { appInvoke } from "@/app/utils/tauri";
import Http from "../http";

interface GLM4 {
  messages: { role: string; content: string }[];
  model: "glm-4";
  stream: boolean;
}
export const ZHI_PU = new (class ZHI_PU extends Http {
  chatCompletion = async (data: GLM4) => {
    const response = await this.post("", {
      body: data,
      headers: {
        Authorization: await appInvoke("create_jwt_token"),
        accept: "text/event-stream",
      },
      isJSON: false,
      allUrl: "https://open.bigmodel.cn/api/paas/v4/chat/completions",
    });
    return response;
  };
})();
